    function clearQik(obj){
        if(Trim(obj.value) == '--'+l1+'--'){
            obj.value = '';
            obj.style.color = 'black';
        }else{
            selectText(obj);
        }
    }

    function reQik(obj){
        if(Trim(obj.value) == ''){
            obj.value = '--'+l1+'--';
            obj.style.color = 'darkgray';
        }
    }

function gotoPrice(obj) {
    if (event.keyCode == 13) {
        var o = document.getElementsByName("linenetprice" + obj.name.substring(8, obj.name.length))[0];
        o.focus();
        var v = o.value;
        if (v != '') {
            selectText(o);
        }
    }
}

function gotoQty(obj) {
    if (event.keyCode == 13) {
        var t = parseInt(obj.name.substring(12, obj.name.length)) + 1;
        var o = document.getElementsByName("orderqty" + t)[0];
        if (o != null) {
            o.focus();
            var v = o.value;
            if (v != '') {
                selectText(o);
            }
        }
    }
}

//??????????????????
function selectText(obj) {
    var range = obj.createTextRange()
    range.moveStart("character", 0);
    range.select();
}

function checkUser() {
    var username = document.cform.username.value;
    var password = document.cform.password.value;
    if (username == '' || username == null) {
        alert(l2);
        return;
    }
    if (password == '' || password == null) {
        alert(l3);
        return;
    }
    subDiv();
}

//??????


function deleteDetail(id) {
    var tableobj = document.getElementById("oTBody");
    var trobj = document.getElementById("tr" + id);
    //var orderdetailid = document.getElementById("orderdetailid" + id).value;
    var numrows = document.cform.numrows.value;
	numrows = numrows - 1;
    tableobj.deleteRow(trobj.rowIndex - 1);
    for (var i = 0; i < oTBody.rows.length; i++)
    {
        oTBody.rows[i].cells[0].innerHTML = parseInt(i) + 1;
    }
    //document.cform.totaldiscountamt.value = '';
    //document.cform.totaldiscount1.value = '';
    //document.cform.totaldiscount.value = '';
    //getSumAmount();

	if ( oTBody.rows.length == 0){	 
		addNewRow(1);
		numrows = 1;
	}
	document.cform.numrows.value = numrows;
}

//????????
function popAtp(num)
{
    var id = document.cform['itemid' + num].value;
    var deptid = document.cform.deptid.value;
    if (isEmpty(id))
        return;
    var status = 1;
    var typeid = 3;
    var whgroupcode = "A";
    if (popwindow != null)popwindow.close();
    var urlstr = "ZopOrderDetailAtp.jsp?"+rurl1+"&deptid=" + deptid + "&itemid=" + id + "&invstatus=" + status + "&ordertypeid=" + typeid + "&whgroupcode=" + whgroupcode;
    var strStatus = "height=250, width=400,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no";
    popwindow = window.open(urlstr, "newwindow", strStatus);
}

//??????


function totalwarehouse(num) {
    var totalavailableqty = document.cform.totalavailableqty.value;
    if (totalavailableqty == 0 && !document.getElementById('sendornot').checked) {
        alert(l4);
        document.cform['warehouseid' + num].options[1].selected = true;
    if (stritemtype == 2) {
        document.cform['buyeritemcode' + num].value = '';
    }else{
        document.cform['selleritemcode' + num].value = '';
    }
        document.getElementById("tr" + num).cells[2].innerHTML = '&nbsp;';
        document.cform['umname' + num].value = '';
        document.cform['itemid' + num].value = '';
        document.cform['unitprice' + num].value = '';
        document.cform['linenetprice' + num].value = '';
        document.cform['spellitemcode' + num].value = '';
        document.getElementById("tr" + num).cells[6].innerHTML = '&nbsp;';
        return;
    }
    document.getElementById('tr' + num).cells[6].innerHTML = '&nbsp;<input type="text" name="availableqty' + num + '" style="text-align:right" value="0" readonly="readonly" style="border:0px;" size="5">/<a onclick="popAtp(' + num + ')">' + numberRound(totalavailableqty, document.cform['orderqty' + num].dataFormat) + '</a>';
}

//????????????????
function warehouse(num) {
    var availableqty = document.cform.availableqty.value;
    var totalavailableqty = document.cform.totalavailableqty.value;
    var endqty = document.cform.totalwarehouseqty.value;
    var orderqty = document.cform['orderqty' + num].value;
    if (document.getElementById('sendornot').checked) {
        document.getElementById('tr' + num).cells[6].innerHTML = '&nbsp;<input type="text" name="availableqty' + num + '" style="text-align:right" value="' + numberRound(availableqty, document.cform['orderqty' + num].dataFormat) + '" readonly="readonly" style="border:0px;" size="5">/<a onclick="popAtp(' + num + ')">' + numberRound(totalavailableqty, document.cform['orderqty' + num].dataFormat) + '</a>';
        return;
    }
    if (totalavailableqty == 0) {
        alert(l4);
        document.cform['warehouseid' + num].options[1].selected = true;
    if (stritemtype == 2) {
        document.cform['buyeritemcode' + num].value = '';
    }else{
        document.cform['selleritemcode' + num].value = '';
    }
        document.getElementById("tr" + num).cells[2].innerHTML = '&nbsp;';
        document.cform['umname' + num].value = '';
        document.cform['itemid' + num].value = '';
        document.cform['unitprice' + num].value = '';
        document.cform['linenetprice' + num].value = '';
        document.cform['spellitemcode' + num].value = '';
        document.getElementById("tr" + num).cells[6].innerHTML = '&nbsp;';
        return;
    }
    if (availableqty == 0 || parseFloat(availableqty) < parseFloat(orderqty)) {
        alert(l5);
        document.cform['warehouseid' + num].value = '';
        document.getElementById('tr' + num).cells[6].innerHTML = '&nbsp;<input type="text" name="availableqty' + num + '" style="text-align:right" value="0" readonly="readonly" style="border:0px;" size="5">/<a onclick="popAtp(' + num + ')">' + numberRound(totalavailableqty, document.cform['orderqty' + num].dataFormat) + '</a>';

        return;
    }
    document.getElementById('tr' + num).cells[6].innerHTML = '&nbsp;<input type="text" name="availableqty' + num + '" style="text-align:right" value="' + numberRound(availableqty, document.cform['orderqty' + num].dataFormat) + '" readonly="readonly" style="border:0px;" size="5">/<a onclick="popAtp(' + num + ')">' + numberRound(totalavailableqty, document.cform['orderqty' + num].dataFormat) + '</a>';
}

//????????????
function page_setWarehouseStuation(num) {

    var itemid = document.cform['itemid' + num].value;
    var warehouseid = document.cform['warehouseid' + num].value;
    var deptid = document.cform.deptid.value;
    if (itemid == '' || itemid == null) {
        alert(l6);
        document.cform['warehouseid' + num].options[1].selected = true;
        return;
    }
    var datahandler = new DataHandler();
    datahandler.add_params("itemid", itemid, "integer");
    datahandler.add_params("deptid", deptid, "integer");
    datahandler.getResult("availableqty", "document.cform.availableqty");
    datahandler.getResult("totalavailableqty", "document.cform.totalavailableqty");
    datahandler.add_job("j_zopgetwarehousestuation");
    if (warehouseid == '' || warehouseid == null) {
        datahandler.add_function("totalwarehouse(" + num + ")");
    } else {
        datahandler.add_function("warehouse(" + num + ")");
        datahandler.add_params("warehouseid", warehouseid, "integer");
    }
    datahandler.runDataHandler();
}

//??????????????


function checkTotalDiscountamt() {
    var totaldiscountamt = Trim(document.cform.totaldiscountamt.value);

    var sumamount = document.cform.subtotalamt.value;
    if (totaldiscountamt == '' || totaldiscountamt == null) {
        checkTotalDiscount();
        return;
    }
    if (Number(totaldiscountamt) > Number(sumamount)) {
        alert(l7);
        document.cform.totaldiscount.value = '';
        document.cform.totaldiscount1.value = '';
        document.cform.totaldiscountamt.value = '';
        document.cform.totalamount.value = sumamount;
        return;
    }
    if (!isNumberic(totaldiscountamt)) {
        alert(l8);
        document.cform.totaldiscount.value = '';
        document.cform.totaldiscount1.value = '';
        document.cform.totaldiscountamt.value = '';
        document.cform.totalamount.value = sumamount;
        return;
    }
    document.cform.totalamount.value = numberRound(parseFloat(sumamount) - parseFloat(totaldiscountamt), document.cform.totalamount.dataFormat);
    document.cform.totaldiscount1.value = '';
    document.cform.totaldiscount.value = '';
    document.cform['totaldiscountamt'].value = numberRound(totaldiscountamt, document.cform['totaldiscountamt'].dataFormat);
}

function checkTotalAmount() {
    var totalamount = Trim(document.cform.totalamount.value);

    var sumamount = document.cform.subtotalamt.value;
    if (totalamount == '' || totalamount == null) {
        checkTotalDiscount();
        return;
    }
    if (Number(totalamount) > Number(sumamount)) {
        alert(l9);
        document.cform.totaldiscount.value = '';
        document.cform.totaldiscount1.value = '';
        document.cform.totaldiscountamt.value = '';
        document.cform.totalamount.value = sumamount;
        return;
    }
    if (!isNumberic(totalamount)) {
        alert(l10);
        document.cform.totaldiscount.value = '';
        document.cform.totaldiscount1.value = '';
        document.cform.totaldiscountamt.value = '';
        document.cform.totalamount.value = sumamount;
        return;
    }
    document.cform.totaldiscountamt.value = numberRound(parseFloat(sumamount) - parseFloat(totalamount), document.cform.totaldiscountamt.dataFormat);
    document.cform.totaldiscount1.value = '';
    document.cform.totaldiscount.value = '';
    document.cform['totalamount'].value = numberRound(totalamount, document.cform['totalamount'].dataFormat);
}

//????????????
function checkTotalDiscount() {
    var temptotaldiscount = Trim(document.cform.totaldiscount1.value);


    var sumamount = document.cform.subtotalamt.value;

    if (temptotaldiscount == '' || temptotaldiscount == null) {
        if (sumamount != null && sumamount != '') {
            document.cform.totalamount.value = sumamount;
            document.cform.totaldiscount.value = '';
            document.cform.totaldiscount1.value = '';
            document.cform.totaldiscountamt.value = '';
        } else {
            document.cform.totalamount.value = '';
            document.cform.totaldiscount.value = '';
            document.cform.totaldiscount1.value = '';
            document.cform.totaldiscountamt.value = '';
        }
        return;
    }

    if (!isNumberic(temptotaldiscount)) {
        alert(l11);
        document.cform.totaldiscount.value = '';
        document.cform.totaldiscountamt.value = '';
        document.cform.totaldiscount1.value = '';
        document.cform.totalamount.value = sumamount;
        return;
    }
    if (temptotaldiscount > 100 || temptotaldiscount < 0) {
        alert(l12);
        document.cform.totaldiscount.value = '';
        document.cform.totaldiscount1.value = '';
        document.cform.totaldiscountamt.value = '';
        document.cform.totalamount.value = sumamount;
        return;
    }
    if (sumamount == null || sumamount == '') {
        return;
    }

    document.cform.totaldiscount.value = temptotaldiscount / 100;
    var totaldiscount = document.cform.totaldiscount.value;
    document.cform.totaldiscountamt.value = numberRound(parseFloat(totaldiscount) * parseFloat(sumamount), document.cform.totaldiscountamt.dataFormat);

    document.cform.totalamount.value = numberRound((1 - parseFloat(totaldiscount)) * parseFloat(sumamount), document.cform.totaldiscountamt.dataFormat);
    document.cform['totaldiscount1'].value = numberRound(temptotaldiscount, document.cform.totaldiscountamt.dataFormat);
}

//????????????
function getSumAmount() {
    var numrows = document.cform.numrows.value;
    var sumamount = 0;
    for (i = 0; i < numrows; i++) {
        var amountObj = document.cform['amount' + i];
        if (amountObj == null) {
            continue;
        }
        var amount = amountObj.value;
        if (amount == '' || amount == null)
            amount = 0;
        sumamount = parseFloat(sumamount) + parseFloat(amount);
    }
    document.cform.subtotalamt.value = numberRound(sumamount, document.cform.subtotalamt.dataFormat);

    var totaldiscount = document.cform.totaldiscount1.value;
    var totaldiscountamt = document.cform.totaldiscountamt.value;

    if (totaldiscount != '' && totaldiscount != null) {
        checkTotalDiscount();
        return;
    }
    if (totaldiscountamt != '' && totaldiscountamt != null) {
        checkTotalDiscountamt();
        return;
    }
    document.cform.totalamount.value = numberRound(sumamount, document.cform.totalamount.dataFormat);
}

//????????

function checkprice(num) {
    var linenetprice = Trim(document.getElementById("linenetprice" + num).value);
    var discountamt = Trim(document.cform['discountamt' + num].value);
    var unitprice = document.cform['unitprice' + num].value;
    var discount = document.cform['discount' + num].value;
    if (document.getElementById("itemid" + num).value == "") {
        alert(l15);
        document.cform['linenetprice' + num].value = '';
        return;
    }
    if (linenetprice == "") {
        alert(l16);
        if (discountamt != '' && discountamt != null) {
            document.cform['linenetprice' + num].value = numberRound(parseFloat(unitprice) - parseFloat(discountamt), document.cform['unitprice' + num].dataFormat);
            return;
        }
        if (discount != '' && discount != null) {
            document.cform['linenetprice' + num].value = numberRound(parseFloat(unitprice) * (1 - parseFloat(discount)), document.cform['unitprice' + num].dataFormat);
            return;
        }
        if (unitprice != '' && unitprice != null) {
            document.cform['linenetprice' + num].value = unitprice;
            return;
        }
        document.cform['amount' + num].value = '';
        getSumAmount();
        return;
    }
    if (!isNumberic(linenetprice)) {
        alert(l13);
        if (discountamt != '' && discountamt != null) {
            document.cform['linenetprice' + num].value = numberRound(parseFloat(unitprice) - parseFloat(discountamt), document.cform['unitprice' + num].dataFormat);
            return;
        }
        if (discount != '' && discount != null) {
            document.cform['linenetprice' + num].value = numberRound(parseFloat(unitprice) * (1 - parseFloat(discount)), document.cform['unitprice' + num].dataFormat);

            return;
        }
        if (unitprice != '' && unitprice != null) {
            document.cform['linenetprice' + num].value = unitprice;
            return;
        }
        document.cform['linenetprice' + num].value = '';
        document.cform['amount' + num].value = '';
        getSumAmount();
        return;
    }
    if (parseFloat(linenetprice) < 0) {
        alert(l14);
        if (discountamt != '' && discountamt != null) {
            document.cform['linenetprice' + num].value = numberRound(parseFloat(unitprice) - parseFloat(discountamt), document.cform['unitprice' + num].dataFormat);
            return;
        }
        if (discount != '' && discount != null) {
            document.cform['linenetprice' + num].value = numberRound(parseFloat(unitprice) * (1 - parseFloat(discount)), document.cform['unitprice' + num].dataFormat);
            return;
        }
        if (unitprice != '' && unitprice != null) {
            document.cform['linenetprice' + num].value = unitprice;
            return;
        }
        document.cform['linenetprice' + num].value = '';
        document.cform['amount' + num].value = '';
        getSumAmount();
        return;
    }
    if (unitprice != '' && unitprice != null) {
        document.cform['discount1' + num].value = '';
        document.cform['discount' + num].value = ' ';
        document.cform['discountamt' + num].value = numberRound((parseFloat(unitprice) - parseFloat(linenetprice)), document.cform['amount' + num].dataFormat);
    }
    var qty = document.cform['orderqty' + num].value;
    if (qty != '' && qty != null) {
        var amount = parseFloat(linenetprice) * parseFloat(qty);
        document.cform['amount' + num].value = numberRound(amount, document.cform['amount' + num].dataFormat);
    }
    getSumAmount();
    document.cform['linenetprice' + num].value = numberRound(linenetprice, document.cform['unitprice' + num].dataFormat);
}





function page_reload() {
    var url = "ZopSaleOrderNew.jsp?"+rurl1;
    document.cform.target = "_self";
    document.cform.action = url;
    document.cform.submit();
}

function page_back() {
    self.location.href = "ZopSaleOrderSummary.jsp";
}

//????????
function page_save() {
    if (!checkAll()) return;
    cform.actionname.value = "save";
    isRunning = true;
    cform.submit();
}

//????????
function page_deleteAllDetail() {
    var orderid = document.cform.orderid.value;
    document.cform.actionname.value = "delete";
    isRunning = true;
    document.cform.submit();
}

//??????????????


function checkAll() {
    if (!formatDate(document.cform)) return false;
	//alert(document.cform.salesrepid.value);
	//alert(document.cform.deptid.value);
	if (document.cform.salesrepid.value == -1) {
            alert(l47);
            return false;
        }
	if (document.cform.deptid.value == -1) {
            alert(l48);
            return false;
        }
    if (document.getElementById('sendornot').checked) {
        if (document.cform.deliverydate.value == '' || document.cform.deliverydate.value == null) {
            alert(l17);
            return false;
        }
        if (document.cform.phone.value == '' || document.cform.phone.value == null) {
          alert(l18);
            return false;
        }
        if (document.cform.deliverydate.value == '' || document.cform.deliverydate.value == null) {
            if (!formatDate(document.cform)) return false;
        }
    }
    
    var tmp_subtotalamt = 0;
    
    var numrows = document.cform.numrows.value;
    for (i = 0; i < numrows; i++) {
        var itemObj = document.cform['itemid' + i];
        if (itemObj == null) {
            if (i < numrows - 1) {
                continue;
            }
            if (i == numrows - 1) {
                break;
            }
        }
        var item = document.cform['itemid' + i].value;
        if (item == '' || item == null) {
            continue;
        }
        var orderqty = Trim(document.cform['orderqty' + i].value);
        var linenetprice = Trim(document.cform['linenetprice' + i].value);
        var warehouseid = document.cform['warehouseid' + i].value;
        var amount = document.cform['amount' + i];
        if (orderqty == '' || orderqty == null) {
            alert(l19);
            return false;
        }
        if (linenetprice == '' || linenetprice == null) {
            alert(l20);
            return false;
        }
        if (warehouseid == '' || warehouseid == null) {
            alert(l21);
            return false;
        }
        if (isEmpty(amount.value)){
       	 	amount.value = numberRound(linenetprice*orderqty, amount.dataFormat);
        }
        tmp_subtotalamt = parseFloat(tmp_subtotalamt) + parseFloat(amount.value);
    }
    var subtotalamt  = document.cform['subtotalamt'];
    tmp_subtotalamt = numberRound(tmp_subtotalamt, subtotalamt.dataFormat);
    if (subtotalamt.value != tmp_subtotalamt){
    		subtotalamt.value = tmp_subtotalamt;
    }
    var totalamt = document.cform['totalamount'];
    if (isEmpty(totalamt.value)) totalamt.value = 0;
    var totaldiscountamt = document.cform['totaldiscountamt'];
    if (isEmpty(totaldiscountamt.value)) totaldiscountamt.value = 0;
    if (tmp_subtotalamt - totaldiscountamt.value != totalamt.value){
    	alert (l48);
    	return false;
    }
    return true;
}


/*
 ????????????JS
 */
//iframe????????
function page_setOrg() {
    var customercode = document.cform.orgcode.value;
    if (customercode == '' || customercode == null) {
        document.cform.orgname.value = '';
        document.cform.buyerid = '9999';
        return;
    }

    var datahandler = new DataHandler();
    datahandler.add_params("orgcode", customercode, "string");
    datahandler.add_params("type", "1", "string");
    datahandler.getResultFromHashMap("orginfo", "orgid", "document.cform.buyerid");
    datahandler.getResultFromHashMap("orginfo", "orgcode", "document.cform.orgcode");
    datahandler.getResultFromHashMap("orginfo", "orgname", "document.cform.orgname");
    datahandler.getResultFromHashMap("orginfo", "taxgroupcode", "document.cform.taxgroupcode");
    datahandler.add_function("hasTaxGroupcodeForOrg()");
    datahandler.add_job("j_zopgetcustomerinfo1");
    datahandler.runDataHandler();
}

//??????????????


function page_setCustomer(orgid, orgcode, orgname, pccodename, taxgroupcode,telephone,contact,address) {
    if (taxgroupcode == '' || taxgroupcode == null) {
        alert(l22);
        return;
    }
    document.cform.buyerid.value = orgid;
    //   document.cform.shipto.value = orgid;
    //   document.cform.billto.value = orgid;
    document.cform.orgcode.value = orgcode;
    document.cform.orgname.value = orgname;
	document.cform.customercontact.value = contact;
	document.cform.phone.value = telephone;
	document.cform.shipaddress.value = address;
    hiddenorg();
   
}
function hiddenorg()
{
    document.getElementById("orgcode").readOnly = true;
    document.getElementById("orga3").style.display ='none';
//    document.getElementById("btnew".style.display='none';
    document.getElementById("orga4").style.display='none';
 
}
//????????????????
function hasTaxGroupcodeForOrg() {
    var taxgroupcode = document.cform.taxgroupcode.value;
    if (taxgroupcode == '' || taxgroupcode == null) {
        alert(l22);
        document.cform.orgcode.value = '';
        document.cform.orgname.value = '';
        document.cform.buyerid.value = '9999';
    }else{
    hiddenorg();
    }
    document.cform.taxgroupcode.value = '';
}

//????????????????
function sendOrNot() {
    if (document.getElementById('sendornot').checked == true) {
//        document.getElementById('addr').style.display = "block";
        document.getElementById("del_date").style.color = "red";
        document.getElementById("del_phone").style.color = "red";
        document.getElementsByName("deliverydate")[0].commond = 'notnull'
        document.getElementsByName("phone")[0].commond = 'notnull'
        document.cform.booking.value = '1';
    } else {
        document.getElementById('sendornot').checked = true;
    }
}

//????????????????
function changeInputStyle() {
    var addr = document.cform.shipaddress;
    if (addr.value == l23) {
        addr.style.color = '#000';
        addr.value = '';
    }
}


/* ????????JS */

//iframe????item
function page_getitem(num) {
    document.getElementById("amount" + num).value = '';
    getSumAmount(num);
    var itemcode;
    if (stritemtype == 2) {
    itemcode = document.cform['buyeritemcode' + num].value;
    }else{
    itemcode = document.cform['selleritemcode' + num].value;
    }
    if (itemcode == '' || itemcode == null) return;
    var datahandler = new DataHandler();
    datahandler.add_params("itemcode", itemcode, "string");
    datahandler.getResultFromHashMap("iteminfo", "itemid", "document.cform.itemid" + num);
    datahandler.getResultFromHashMap("iteminfo", "umcode", "document.cform.umcode" + num);
    datahandler.getResultFromHashMap("iteminfo", "prdn", "document.cform.prdn");
    datahandler.getResultFromHashMap("iteminfo", "prodid", "document.cform.prodid" + num);
    datahandler.getResultFromHashMap("iteminfo", "umname", "document.cform.umname" + num);
    datahandler.getResultFromHashMap("iteminfo", "listprice", "document.cform.unitprice" + num);
    datahandler.getResultFromHashMap("iteminfo", "listprice", "document.cform.linenetprice" + num);
    datahandler.getResultFromHashMap("iteminfo", "taxgroupcode", "document.cform.taxgroupcode");
    datahandler.getResultFromHashMap("iteminfo", "itemcode", "document.cform.itemcode" + num);
    datahandler.getResultFromHashMap("iteminfo", "piece", "document.cform.piece" + num);
	datahandler.getResultFromHashMap("iteminfo", "picturename", "document.cform.picturename" + num);
	datahandler.getResultFromHashMap("iteminfo", "picturepath", "document.cform.picturepath" + num);
    
	
	

	datahandler.add_function("hasTaxGroupcodeFor(" + num + "," + stritemtype + ")");
    datahandler.add_function("getWholesalePrice(" + num + ")");
    datahandler.add_job("j_zopgetiteminfo1");
    datahandler.runDataHandler();

    document.getElementById("orderqty" + num).value = '';
    document.getElementById("discount" + num).value = '';
    document.getElementById("discountamt" + num).value = '';
    document.getElementById("linenetprice" + num).value = '';
    document.getElementById("amount" + num).value = '';
    document.getElementById("spellitemcode" + num).value = '';
    document.getElementById("tr" + num).cells[2].innerHTML = '&nbsp;';
    document.getElementById("tr" + num).cells[6].innerHTML = '&nbsp;';
    
}




//????????????????
function hasTaxGroupcodeFor(num,stritemtype) {

    document.cform['orderqty' + num].focus();

    var taxgroupcode = document.cform.taxgroupcode.value;
    //document.getElementById("tr" + num).cells[2].innerHTML = document.cform.prdn.value;

	tempshowpic(num,stritemtype);
    document.getElementById("tr" + num).cells[5].innerHTML ="&nbsp;" + document.cform['piece' + num].value;
    if (taxgroupcode == '' || taxgroupcode == null) {
        alert(l22);
    if (stritemtype == 2) {
        document.cform['buyeritemcode' + num].value = '';
    }else{
        document.cform['selleritemcode' + num].value = '';
    }
        document.getElementById("tr" + num).cells[2].innerHTML = '&nbsp;';
        document.cform['umname' + num].value = '';
        document.cform['unitprice' + num].value = '';
        document.cform['linenetprice' + num].value = '';
        document.cform['spellitemcode' + num].value = '';
        document.getElementById("tr" + num).cells[6].innerHTML = '&nbsp;';
        return;
    }
    //page_setWarehouseStuation(num);
    document.cform.taxgroupcode.value = '';
}


//Item??????
function page_itemselectCheck(rootpath,params)
{
	var popurl = "masterdata/pcm/ItemSelectForPOCheck.jsp" + params;
	top.addWindow(popurl,L47,top.aw+'_POP');
	
}

function popitem(quickObj) { 

    var qic = "";
    if(quickObj != null){
        qic = Trim(quickObj.value);
    }

    var buyerid = document.cform.buyerid.value;
    var deptid = document.cform.deptid.value;
    var warehouseid = document.cform['warehouseid'].value;
    var flag = 'N';
    if (document.getElementById("sendornot").checked) {
        flag = 'Y';
    } else {
        flag = 'N';
    }
if (stritemtype == 2) {
    page_itemselectCheck('../../', "?"+rurl1+"&orgid="+norgid+"&selectopt=all&ispoitem=Y&param="+jparam+"&sellerid="+norgid+"&buyerid=" + buyerid + "&deptid=" + deptid + "&warehouseid=" + warehouseid + "&flag=" + flag + "&itemspellcode=" + qic);
}else{
    page_itemselectCheck('../../', "?"+rurl1+"&orgid="+norgid+"&selectopt=all&ispoitem=N&param="+jparam+"&sellerid="+norgid+"&buyerid=" + buyerid + "&deptid=" + deptid + "&warehouseid=" + warehouseid + "&flag=" + flag + "&itemspellcode=" + qic);
}
}

//??????????item
function page_setItem1() {
    page_setItem();
}

function page_setItem() {
    var currentindex = document.cform.currentindex.value;

    document.getElementById("orderqty" + currentindex).value = '';
    document.getElementById("orderqty" + currentindex).focus();
    document.getElementById("discount" + currentindex).value = '';
    document.getElementById("discountamt" + currentindex).value = '';
    document.getElementById("linenetprice" + currentindex).value = '';
    document.getElementById("amount" + currentindex).value = '';
    document.getElementById("amount" + currentindex).value = '';
    document.getElementById("tr" + currentindex).cells[6].innerHTML = '&nbsp;';

    document.cform['itemid' + currentindex].value = arguments[0];
    document.cform['umcode' + currentindex].value = arguments[3];
    document.cform['umname' + currentindex].value = arguments[4];
    document.cform['unitprice' + currentindex].value = arguments[6];
    document.cform['linenetprice' + currentindex].value = arguments[6];
    document.getElementById("tr" + currentindex).cells[2].innerHTML = arguments[2];
    document.cform['itemcode' + currentindex].value = arguments[1];
    document.cform['prodid' + currentindex].value = arguments[10];
    document.cform['piece' + currentindex].value = arguments[11];
if (stritemtype == 2) {
    document.getElementById("buyeritemcode" + currentindex).value = arguments[1];
    document.getElementById("buyeritemid" + currentindex).value = arguments[0];
    document.getElementById("buyerumcode" + currentindex).value = arguments[3];
    document.getElementById("buyeritemname" + currentindex).value = arguments[2];
}else{
    document.getElementById("selleritemcode" + currentindex).value = arguments[1];
    document.getElementById("selleritemid" + currentindex).value = arguments[0];
    document.getElementById("sellerumcode" + currentindex).value = arguments[3];
    document.getElementById("selleritemname" + currentindex).value = arguments[2];
    document.getElementById("shipfromitemcode" + currentindex).value = arguments[1];
    document.getElementById("shipfromitemid" + currentindex).value = arguments[0];
}

    //????????????
    page_setWarehouseStuation(currentindex);
}


String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

//??????????item
function page_setItem1Check() {
    page_setItemCheck();
}

function page_setItemCheck() {

    var numrows = oTBody.rows.length;
    for (var i = 0; i < numrows; i++) {
        if (oTBody.rows.item(i).cells.item(2).innerText.trim() == "") {
            var t = oTBody.rows.item(i).id;
            var id = t.substr(2, t.length);
            page_itemValue(id, arguments);
            return;
        } else if (oTBody.rows.item(i).cells.item(2).innerText.trim() != "" && i == numrows - 1) {
            addNewRow(5);
            var t = oTBody.rows.item(i).id;
            var id = t.substr(2, t.length);
            page_itemValue(parseInt(id) + 1, arguments);
            return;
        }
    }
}


function checkqty1(num,availableqty,totalavailableqty){
    var qty = Trim(document.getElementById("orderqty" + num).value);

    if (document.getElementById("itemid" + num).value == "") {
        alert(l15);
        document.getElementById("orderqty" + num).value = '';
        return;
    }
    if (qty == '' || qty == null) {
        document.cform['amount' + num].value = '';
        getSumAmount();
        return;
    }
    if (!isNumberic(qty) || parseFloat(qty) <= 0) {
        alert(l24);
        document.getElementById("orderqty" + num).value = '';
        document.cform['amount' + num].value = '';
        getSumAmount();
        return;
    }
    document.cform['orderqty' + num].value = numberRound(qty, document.cform['orderqty' + num].dataFormat);
    var linenetprice = document.cform['linenetprice' + num].value;
    if (linenetprice != '' && linenetprice != null) {
        var amount = parseFloat(linenetprice) * parseFloat(qty);
        document.cform['amount' + num].value = numberRound(amount, document.cform['amount' + num].dataFormat);

    }
    getSumAmount();
    
    var trobj=document.getElementById("tr"+num);
    if(document.getElementById("piece"+num).value!="" && parseInt(document.getElementById("piece"+num).value)>0){
	      var intnum=parseInt(document.getElementById("orderqty"+num).value)%parseInt(document.getElementById("piece"+num).value);
	      var vnum=document.getElementById("piece"+num).value;
	      if(intnum!=0){
	       
	       trobj.cells[5].innerHTML = vnum + "&nbsp;<img src='../../images/cn/er1.gif' style='border:none' alt=''>&nbsp;";
	      }else{
	       trobj.cells[5].innerHTML = vnum + "&nbsp;<img src='../../images/cn/ok1.gif' style='border:none'>&nbsp;";
	      }
      }
   
	  if (availableqty == 0 || parseFloat(availableqty) < parseFloat(qty)) {
	        alert(l5);
	        document.cform['warehouseid' + num].value = '';
	        document.getElementById('tr' + num).cells[6].innerHTML = '&nbsp;<input type="text" name="availableqty' + num + '" style="text-align:right" value="0" readonly="readonly" style="border:0px;" size="5">/<a onclick="popAtp(' + num + ')">' + numberRound(totalavailableqty, document.cform['orderqty' + num].dataFormat) + '</a>';
            return;
	    }
}

function getWholesalePrice(num) {
	//alert('getWholesalePrice');
	return;
    var prodid = document.cform['prodid' + num].value;
    var buyerid = document.cform.buyerid.value;
   
    var datahandler = new DataHandler();
    datahandler.add_params("prodid", prodid, "integer");
    datahandler.add_params("buyerid", buyerid, "integer");
    datahandler.getResultFromHashMap("wholesalepriceinfo", "wholesaleprice", "document.cform.linenetprice" + num);
    datahandler.getResultFromHashMap("wholesalepriceinfo", "wholesaleprice", "document.cform.unitprice" + num);
    //datahandler.add_function("hasTaxGroupcodeFor("+num+")");
    datahandler.add_function("haswholesaleprice(" + num + ")");
    datahandler.add_job("j_zopgetretailsaleprice");
    datahandler.runDataHandler();
}

function haswholesaleprice(num) { 

    var wholesaleprice = document.cform['linenetprice' + num].value;
    if(wholesaleprice==null || wholesaleprice ==""){
    	document.cform['linenetprice' + num].value = "0.0";
    	document.cform['unitprice' + num].value ="0.0";
    }
    document.cform.prdn.value="";
   // document.getElementById("tr" + num).cells[2].innerHTML = document.cform.prdn.value;
   
   // if (wholesaleprice == '' || wholesaleprice == null || parseFloat(wholesaleprice)==0) {
   //     alert(l46);
  //      document.cform['itemid' + num].value = '';
  //  if(stritemtype == 2){ 
  //      document.getElementById("spellitemcode" + num).value = '';
  //      document.getElementById("buyeritemcode" + num).value = '';
  //      document.getElementById("buyeritemid" + num).value = '';
  //      document.getElementById("buyerumcode" + num).value = '';
  //      document.getElementById("buyeritemname" + num).value = '';
  //  }else{
  //      document.getElementById("spellitemcode" + num).value = '';
  //      document.getElementById("selleritemcode" + num).value = '';
  //      document.getElementById("selleritemid" + num).value = '';
  //      document.getElementById("sellerumcode" + num).value = '';
   //     document.getElementById("selleritemname" + num).value = '';
  //      document.getElementById("shipfromitemcode" + num).value = '';
  //     document.getElementById("shipfromitemid" + num).value = '';
  //  }
 //      document.cform['umcode' + num].value = '';
   //     document.cform['umname' + num].value = '';
   //    document.cform['linenetprice' + num].value = '';
   //    document.cform['unitprice' + num].value = '';
   //    document.cform['orderqty' + num].value = '';
   //     document.cform['amount' + num].value = '';
   //    document.getElementById("tr" + num).cells[2].innerHTML = '&nbsp;';
    //     document.getElementById("tr" + num).cells[5].innerHTML = '&nbsp;';
   //     return;
   // }
   
    //?????????
 page_setWarehouseStuation(num);
}
//????????
function checkqty(num) {
    var qty = Trim(document.getElementById("orderqty" + num).value);

    if (document.getElementById("itemid" + num).value == "") {
        alert(l15);
        document.getElementById("orderqty" + num).value = '';
        return;
    }
    if (qty == '' || qty == null) {
        document.cform['amount' + num].value = '';
        getSumAmount();
        return;
    }
    if (!isNumberic(qty) || parseFloat(qty) <= 0) {
        alert(l24);
        document.getElementById("orderqty" + num).value = '';
        document.cform['amount' + num].value = '';
        getSumAmount();
        return;
    }
    document.cform['orderqty' + num].value = numberRound(qty, document.cform['orderqty' + num].dataFormat);
    var linenetprice = document.cform['linenetprice' + num].value;
    if (linenetprice != '' && linenetprice != null) {
        var amount = parseFloat(linenetprice) * parseFloat(qty);
        document.cform['amount' + num].value = numberRound(amount, document.cform['amount' + num].dataFormat);

    }
    getSumAmount();
    
    var trobj=document.getElementById("tr"+num);
    if(document.getElementById("piece"+num).value!="" && parseInt(document.getElementById("piece"+num).value)>0){
	      var intnum=parseInt(document.getElementById("orderqty"+num).value)%parseInt(document.getElementById("piece"+num).value);
	      var vnum=document.getElementById("piece"+num).value;
	      if(intnum!=0){
	       
	       trobj.cells[5].innerHTML = vnum + "&nbsp;<img src='../../images/cn/er1.gif' style='border:none' alt=''>&nbsp;";
	      }else{
	       trobj.cells[5].innerHTML = vnum + "&nbsp;<img src='../../images/cn/ok1.gif' style='border:none'>&nbsp;";
	      }
      }
    
    if (document.cform['warehouseid' + num].value != '' && document.cform['warehouseid' + num].value != null) {
        page_setWarehouseStuation(num);
    }
}

//????????
function checkDiscount(num) {
    if (document.getElementById("itemid" + num).value == "") {
        alert(l15);
        document.cform['discount1' + num].value = '';
        document.cform['discount' + num].value = ' ';
        return;
    }
    var unitprice = document.cform['unitprice' + num].value;

    var tempDiscount = Trim(document.cform['discount1' + num].value);
    document.cform['discount' + num].value = tempDiscount / 100;

    var discount = document.cform['discount' + num].value;
    if (tempDiscount != '' && tempDiscount != null) {
        if (!isNumberic(discount)) {
            alert(l25);
            document.cform['discount1' + num].value = '';
            document.cform['discount' + num].value = ' ';
            return;
        }
        if (parseFloat(tempDiscount) > 100 || parseFloat(tempDiscount) < 0) {
            alert(l26);
            document.cform['discount1' + num].value = '';
            document.cform['discount' + num].value = ' ';
            return;
        }

        if (unitprice == null || unitprice == '' || Number(unitprice) == 0) {
            document.cform['discount1' + num].value = '';
            document.cform['discount' + num].value = ' ';
            return;
        }

        if (unitprice != '' && unitprice != null) {
            document.cform['linenetprice' + num].value = numberRound(parseFloat(unitprice) * (1 - parseFloat(discount)), document.cform['linenetprice' + num].dataFormat);

            document.cform['discountamt' + num].value = numberRound(parseFloat(unitprice) * parseFloat(discount), document.cform['amount' + num].dataFormat);

            var qty = document.cform['orderqty' + num].value;
            var linenetprice = document.cform['linenetprice' + num].value;
            if (qty != '' && qty != null) {
                var amount = parseFloat(linenetprice) * parseFloat(qty);
                document.cform['amount' + num].value = numberRound(amount, document.cform['amount' + num].dataFormat);
            }
            getSumAmount();
        }
    } else {
        if (unitprice != '' && unitprice != null) {
            document.cform['linenetprice' + num].value = unitprice;
        } else {
            document.cform['linenetprice' + num].value = 0;
        }
        checkprice(num);
    }
    document.cform['discount1' + num].value = numberRound(tempDiscount, document.cform['amount' + num].dataFormat);
}

//????????????
function checkDiscountAmt(num) {
    if (document.getElementById("itemid" + num).value == "") {
        alert(l15);
        document.getElementById("discountamt" + num).value = '';
        return;
    }

    var discountamt = Trim(document.cform['discountamt' + num].value);
    var unitprice = document.cform['unitprice' + num].value;
    var discount = document.cform['discount' + num].value;

    if (discountamt != '' && discountamt != null) {
        if (!isNumberic(discountamt)) {
            alert(l27);
            if (discount != '' && discount != null) {
                document.cform['discountamt' + num].value = numberRound(parseFloat(unitprice) * parseFloat(discount), document.cform['amount' + num].dataFormat);
            } else {
                document.cform['discountamt' + num].value = '';
            }
            checkprice(num);
            return;
        }
        if (Number(discountamt) > Number(unitprice)) {
            alert(l28);
            document.cform['discountamt' + num].value = '';
            checkprice(num);
            return;
        }
        if (unitprice == null || unitprice == '' || Number(unitprice) == 0) {
            document.cform['discountamt' + num].value = '';
            return;
        }
        if (unitprice != '' && unitprice != null) {
            document.cform['discount1' + num].value = '';
            document.cform['discount' + num].value = ' ';
            document.cform['linenetprice' + num].value = numberRound(parseFloat(unitprice) - parseFloat(discountamt), document.cform['linenetprice' + num].dataFormat);
            checkprice(num);
        }
    } else {
        if (unitprice != '' && unitprice != null) {
            document.cform['linenetprice' + num].value = unitprice;
        } else {
            document.cform['linenetprice' + num].value = 0;
        }
        checkprice(num);
    }
    document.cform['discountamt' + num].value = numberRound(discountamt, document.cform['amount' + num].dataFormat);
}

//??????????


function checkAtLeast(numrows) {
    for (i = 0; i < numrows; i++) {
        var itemObj = document.cform['itemid' + i];
        if (itemObj == null) {
            if (i < numrows - 1) {
                continue;
            }
            if (i == numrows - 1) {
                return false;
            }
        }
        var item = document.cform['itemid' + i].value;
        var orderqty = document.cform['orderqty' + i].value;
        var linenetprice = document.cform['linenetprice' + i].value;
        var warehouseid = document.cform['warehouseid' + i].value;
        if (item != '' && item != null && orderqty != '' && orderqty != null
                && linenetprice != '' && linenetprice != '' && warehouseid != '' && warehouseid != null) {
            return true;
        }
    }
    return false;
}

function beforeShow() {
    var buyer = document.cform.buyerid.value;
    if (buyer == '' || buyer == null) {
        alert(l29);
        return;
    }

    var salesrep = document.cform.salesrepid.value;
    if (salesrep == ' ' || salesrep == null) {
        alert(l30);
        return;
    }

    var deptid = document.cform.deptid.value;
    if (deptid == ' ' || deptid == null) {
        alert(l31);
        return false;
    }

    if (document.getElementById('sendornot').checked) {
        if (document.cform.deliverydate.value == '' || document.cform.deliverydate.value == null) {
            alert(l32);
            return false;
        }
        if (document.cform.phone.value == '' || document.cform.phone.value == null) {
            alert(l33);
            return false;
        }
        if (document.cform.deliverydate.value == '' || document.cform.deliverydate.value == null) {
            if (!formatDate(document.cform)) return false;
        }
    }

    var numrows = document.cform.numrows.value;

    for (i = 0; i < numrows; i++) {
        var itemObj = document.cform['itemid' + i];
        if (itemObj == null) {
            if (i < numrows - 1) {
                continue;
            }
            if (i == numrows - 1) {
                break;
            }

        }
        var item = document.cform['itemid' + i].value;
        if (item == '' || item == null) {
            continue;
        }
        var orderqty = document.cform['orderqty' + i].value;
        var linenetprice = document.cform['linenetprice' + i].value;
        var warehouseid = document.cform['warehouseid' + i].value;
        if (orderqty == '' || orderqty == null) {
            alert(l34);
            return false;
        }
        if (linenetprice == '' || linenetprice == null) {
            alert(l35);
            return false;
        }
        if (warehouseid == '' || warehouseid == null) {
            alert(l36);
            return false;
        }
    }
    if (!checkAtLeast(numrows)) {
        alert(l37);
        return false;
    }
    return true;
}

//????????DIV
function showDiv(element) {
    var W = document.documentElement.scrollWidth;
    var H = document.documentElement.scrollHeight;
    var selfW = document.getElementById(element).style.width;
    var selfH = document.getElementById(element).style.height;
    document.getElementById(element).style.left = (W - parseInt(selfW)) / 2 + 'px';
    document.getElementById(element).style.top = (H - parseInt(selfH)) / 2 + 'px';
    document.getElementById(element).style.display = 'block';
    var mDiv = document.getElementById("mDiv");
    mDiv.style.display = '';  
    if (element == 'submit') {
        var totalamount = document.cform.totalamount.value;
        document.cform.aramt.value = totalamount;
        document.cform.aramt.value = totalamount;
        document.cform.paymentamt.value = totalamount;
        document.cform.recamount.value = totalamount;
        document.cform.overdraft.value = 0;
        document.cform.changeamt.value = 0;
        document.cform.recamount.readOnly = false;
    } else {
        document.cform.aramt.value = '';
        document.cform.aramt.value = '';
        document.cform.paymentamt.value = '';
        document.cform.recamount.value = '';
        document.cform.overdraft.value = '';
        document.cform.changeamt.value = '';
    }
    if (element == 'submit') {
        document.cform.subbutton.focus();
    }/*else {
        document.cform.username.focus();
    }*/
    if (element == 'error'){
    	document.erfrm.location.href = "../../Error.jsp?button=none";
    }
}

//????????DIV
function hidDiv(element) {
    document.cform.aramt.value = '';
    document.cform.paymentamt.value = '';
    document.cform.recamount.value = '';
    document.cform.overdraft.value = '';
    document.cform.changeamt.value = '';

//    document.cform.paymenttype.value = '';
//    document.cform.paymentobj.value = '';
//    document.cform.amout.value = '';
    
    document.getElementById(element).style.display = 'none';
    document.getElementById("mDiv").style.display = 'none';
}

//????DIV
function subDiv() {
    if (!formatDate(document.cform)) return false;
    if (!beforeShow()) return;
    cform.actionname.value = "submit";
    isRunning = true;
    cform.submit();
}

//????????
function resetAmount(aramt, recamt) {
    var PRAssignAmt = Number(document.cform.prepayassignamt.value);
    if (recamt + PRAssignAmt > aramt) {
        document.cform.overdraft.value = 0;
        document.cform.paymentamt.value = numberRound((aramt - PRAssignAmt), document.cform.changeamt.dataFormat);
        document.cform.changeamt.value = numberRound((recamt + PRAssignAmt - aramt), document.cform.changeamt.dataFormat);
    } else {
        document.cform.overdraft.value = numberRound((aramt - recamt - PRAssignAmt), document.cform.overdraft.dataFormat);
        document.cform.paymentamt.value = recamt;
        document.cform.recamount.value = recamt;
        document.cform.changeamt.value = 0;
    }
}

//??????????????


function checkPRAssignAmt() {
    document.cform.recamount.readOnly = false;
    var PRAssignAmt = Number(document.cform.prepayassignamt.value);
    var prepaybalance = Number(document.cform.prepaybalance.value);
    var aramt = Number(document.cform.aramt.value);
    var payamt = Number(document.cform.paymentamt.value);
    var recamt = Number(document.cform.recamount.value);

    if (!notNegative(document.cform.prepayassignamt.value)) {
        alert(l38);
        document.cform.prepayassignamt.value = 0.00;
        document.cform.prepayassignamt.focus();
        return;
    }

    if (PRAssignAmt > prepaybalance) {
        alert(l39);
        document.cform.prepayassignamt.value = 0.00;
        document.cform.prepayassignamt.focus();
        return;
    }

    if (PRAssignAmt > aramt) {
        alert(l40);
        document.cform.prepayassignamt.value = 0.00;
        document.cform.prepayassignamt.focus();
        return;
    }

    document.cform.paymentamt.value = numberRound((aramt - PRAssignAmt), document.cform.overdraft.dataFormat);
    document.cform.recamount.value = numberRound((aramt - PRAssignAmt), document.cform.overdraft.dataFormat);
    var payamt = Number(document.cform.paymentamt.value);
    var recamt = Number(document.cform.recamount.value);
    document.cform.overdraft.value = numberRound((aramt - payamt - PRAssignAmt), document.cform.overdraft.dataFormat);
    document.cform.changeamt.value = numberRound((recamt - payamt), document.cform.changeamt.dataFormat);
}

//??????????????????
function changePay() {
    document.cform.recamount.readOnly = false;
    var PRAssignAmt = Number(document.cform.prepayassignamt.value);
    var aramt = Number(document.cform.aramt.value);
    var payamt = Number(document.cform.paymentamt.value);
    var recamt = Number(document.cform.recamount.value);

    if (!notNegative(document.cform.paymentamt.value)) {
        alert(l41);
        resetAmount(aramt, recamt);
        document.cform.paymentamt.focus();
        return;
    }

    if (PRAssignAmt + payamt > aramt) {
        alert(l42);
        resetAmount(aramt, recamt);
        document.cform.paymentamt.focus();
        return;
    }

    if (payamt == 0 || payamt == '' || payamt == null) {
        document.cform.overdraft.value = numberRound((aramt - payamt - PRAssignAmt), document.cform.overdraft.dataFormat);
        document.cform.paymentamt.value = 0;
        document.cform.recamount.value = 0;
        document.cform.changeamt.value = 0;
        document.cform.recamount.readOnly = true;
        return;
    }

    if (recamt == 0) {
        resetAmount(aramt, payamt);
        return;
    }

    if (payamt > recamt) {
        alert(l43);
        resetAmount(aramt, recamt);
        document.cform.paymentamt.focus();
        return;
    }
    document.cform.overdraft.value = numberRound((aramt - payamt - PRAssignAmt), document.cform.overdraft.dataFormat);
    var recamt = Number(document.cform.recamount.value);
    document.cform.changeamt.value = numberRound((recamt - payamt), document.cform.changeamt.dataFormat);
}

//??????????????????


function changeRec() {
    var payamt = Number(document.cform.paymentamt.value);
    var recamt = Number(document.cform.recamount.value);

    if (!notNegative(document.cform.recamount.value)) {
        alert(l44);
        document.cform.recamount.value = payamt;
        document.cform.changeamt.value = 0;
        document.cform.recamount.focus();
        return;
    }

    if (payamt > recamt) {
        alert(l45);
        document.cform.recamount.value = payamt;
        document.cform.changeamt.value = 0;
        document.cform.recamount.focus();
        return;
    }

    document.cform.changeamt.value = numberRound((recamt - payamt), document.cform.changeamt.dataFormat);
}

function changecolor1(i){
	document.getElementById("umname"+i).style.background='#E5EFF1';
	document.getElementById("amount"+i).style.background='#E5EFF1';
	document.getElementById("amount"+i).style.background='#E5EFF1';
	document.getElementById("unitprice"+i).style.background='#E5EFF1';
	if(document.getElementById("availableqty"+i)!=null){
		document.getElementById("availableqty"+i).style.background='#E5EFF1';
	}
}

function changecolor2(i){
	document.getElementById("umname"+i).style.background='';
	document.getElementById("amount"+i).style.background='';
	document.getElementById("amount"+i).style.background='';
	document.getElementById("unitprice"+i).style.background='';
	if(document.getElementById("availableqty"+i)!=null){
		document.getElementById("availableqty"+i).style.background='';
	}
}

function page_print()
{
	self.location.href="../../common/OK.jsp?orderid="+document.cform.orderid.value+"&soprint10=1&"+rurl1;
}

function popitem_local(quickObj) { 

    var str = "";
    var qic = "";
    if(quickObj != null){
        qic = Trim(quickObj.value);
    }

    
    var buyerid = document.cform.buyerid.value;
    var deptid = document.cform.deptid.value;
    var warehouseid = document.cform['warehouseid'].value;
    var flag = 'N';
    if (document.getElementById("sendornot").checked) {
        flag = 'Y';
    } else {
        flag = 'N';
    }

		if (stritemtype == 2) {
				str = "ZopItemSelectFrm.jsp?"+rurl1+"&maxitem=12&orgid="+norgid+"&selectopt=all&ispoitem=Y&param="+jparam+"&sellerid="+norgid+"&buyerid=" + buyerid + "&deptid=" + deptid + "&warehouseid=" + warehouseid + "&flag=" + flag + "&itemspellcode=" + qic;
		}else{
	    	str = "ZopItemSelectFrm.jsp?"+rurl1+"&&maxitem=12orgid="+norgid+"&selectopt=all&ispoitem=N&param="+jparam+"&sellerid="+norgid+"&buyerid=" + buyerid + "&deptid=" + deptid + "&warehouseid=" + warehouseid + "&flag=" + flag + "&itemspellcode=" + qic;
		}
		return str;
}

